package com.logica.mdm.webfrontend.models.party;

import java.io.Serializable;
import java.util.Date;

import javax.validation.constraints.Past;

import org.apache.commons.lang.StringUtils;

/**
 * Party search parameters.
 * @author Fabien Crespel <fabien.crespel@logica.com>
 */
public class PartySearchParams implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	private String firstName;
	private String lastName;
	@Past
	private Date birthDate;
	private String streetNumber;
	private String streetType;
	private String streetName;
	private String postalCode;
	private String city;
	private String telephoneNumber;
	private String emailAddress;
	private String rootUrl;
	
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public String getStreetNumber() {
		return streetNumber;
	}

	public void setStreetNumber(String streetNumber) {
		this.streetNumber = streetNumber;
	}

	public String getStreetType() {
		return streetType;
	}

	public void setStreetType(String streetType) {
		this.streetType = streetType;
	}

	public String getStreetName() {
		return streetName;
	}

	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getTelephoneNumber() {
		return telephoneNumber;
	}

	public void setTelephoneNumber(String telephoneNumber) {
		this.telephoneNumber = telephoneNumber;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}
	
	/**
	 * Method that return the address as a  concatenation
	 * of streetNumber, streetType and streetName
	 * @return the result address
	 */
	public String getAddress() {
		String result = StringUtils.join(new String[]{streetNumber, streetType, streetName}, " ");
		
		return result.trim().replaceAll(" +", " "); // removes all the unnecessary spaces
	}

	/**
	 * @return the rootUrl
	 */
	public String getRootUrl() {
		return rootUrl;
	}

	/**
	 * @param baseUrl the rootUrl to set
	 */
	public void setRootUrl(String rootUrl) {
		this.rootUrl = rootUrl;
	}
	
	
}
